<template>
  <div class="context">
    <!--搜索框-->
    <!-- <el-input style="width: 400px; margin: 20px 20px 20px 20px" v-model="inputValue" placeholder="请输入内容"
      prefix-icon="el-icon-search">
    </el-input> -->
    <div class="cardheard">
      <el-button type="primary" @click="showadd" style="height: 40px; margin: 0px 0px 0px 20px">
        系统配置</el-button>
    </div>


    <template>
      
    </template>



<template>
    <el-dialog
      title="系统配置"
      :visible.sync="dialogresetVisible"
      width="30%"
      center
    >
      <el-form>
        <el-form-item label="单价" :label-width="formLabelWidth">
          <el-input v-model="sysinfo.money" autocomplete="off"></el-input>
        </el-form-item>

        
        <el-form-item label="版本号" :label-width="formLabelWidth">
          <el-input v-model="sysinfo.version" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="系统公告" :label-width="formLabelWidth">
          <el-input v-model="sysinfo.mes" autocomplete="off"></el-input>
        </el-form-item>



        <el-form-item label="开屏广告时长" :label-width="formLabelWidth">
          <el-input v-model="sysinfo.adwaittime" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="等待广告市场" :label-width="formLabelWidth">
          <el-input v-model="sysinfo.waittime" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="当前系统状态：" :label-width="formLabelWidth">
         <div v-if="sysinfo.status==0">开启中....</div>
         <div v-if="sysinfo.status==1">关闭中....</div>
        </el-form-item>

        <el-form-item label="系统开关" :label-width="formLabelWidth">
          <el-select v-model="sysinfo.status" placeholder="请选择">
        <el-option
       v-for="item in options"
       :key="item.value"
        :label="item.label"
        :value="item.value">
     </el-option>
     </el-select>

     </el-form-item>



      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogresetVisible = false">取 消</el-button>
        <el-button type="primary" @click="update">确 定</el-button>
      </div>
    </el-dialog>
  </template>



  </div>
</template>

<script>
export default {
  data() {
    return {
      options: [{
          value: 0,
          label: '系统开启'
        }, {
          value: 1,
          label: '系统关闭'
        } ],
      dialogresetVisible:false,
      formLabelWidth: "120px",
      sysinfo:{
        id:1,
        waittime:0,
        money:0,
        adwaittime:0,
        version:0,
        status:0,
        mes:""
      },

    };
  },
  
  created() {
    this.pushdata();
  },
  methods: {
    showadd(){
      this.dialogresetVisible=true
    },

    update(scope,row){
      console.log(this.sysinfo);
      var that = this;
      that.$axios
        .post("/api/Sys/update",{
        id:1,
        waittime:that.sysinfo.waittime,
        money:that.sysinfo.money,
        adwaittime:that.sysinfo.adwaittime,
        version:that.sysinfo.version,
        status:that.sysinfo.status,
        mes:that.sysinfo.mes
        })
        .then(function(response) {
          that.$message.success({
            message: response.data.mes
          });
        })
        .catch(function(error) {
          console.log(error);
          that.$message({
            message: "操作失败"
          });
        });
        that.dialogresetVisible=false
        that.pushdata()
    },

    pushdata() {
      var that = this;
      that.$axios.post("/api/Sys/read")
        .then(function (response) {

          console.log(response.data);
          if (response.data.code == 200) {
            that.sysinfo = response.data.data
          } else {
            that.$message.error(response.data.mes);
          }
        })
        .catch(function (error) {
          that.$message.error('网络链接超时！');
          console.log(error);
        });
    }
  }
};
</script>

<style scoped>

</style>
